package com.example.hhh.service.impl;

import com.example.hhh.model.WorkOrder;
import com.example.hhh.repository.WorkOrderRepository;
import com.example.hhh.service.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class WorkOrderServiceImpl implements WorkOrderService {

    private final WorkOrderRepository workOrderRepository;

    @Autowired
    public WorkOrderServiceImpl(WorkOrderRepository workOrderRepository) {
        this.workOrderRepository = workOrderRepository;
    }

    @Override
    public WorkOrder createWorkOrder(WorkOrder workOrder) {
        return workOrderRepository.save(workOrder);
    }

    @Override
    public List<WorkOrder> getOrdersByCustomer(Integer customerId) {
        return workOrderRepository.findByCustomerId(customerId);
    }

    @Override
    public List<WorkOrder> getOrdersByStaff(Integer staffId) {
        return workOrderRepository.findByAssignedTo(staffId);
    }
}